<template>
  <div class="clientType">
    <div class="title-container">
      <div class="left-box">
        <el-form ref="form" :model="searchForm" :inline="true" class="formClass">
          <el-form-item>
            <el-input
              prefix-icon="el-icon-search"
              type="input"
              placeholder="请输入客户名称"
              v-model="searchForm.companyName"
              style="margin-right: 10px;"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="searchClick">搜索</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <global-card>
      <template #leftTitle>
        <el-button type="success" icon="el-icon-refresh" @click="refresh">刷新</el-button>
      </template>
      <template #content>
        <el-table
          v-loading="loading"
          :data="tableData"
          border
          style="width: 100%"
          class="elTable"
        >
          <el-table-column type="index" label="序号" width="80" align="center"/>
          <el-table-column prop="companyName" label="客户编码" align="center"/>
          <el-table-column prop="legalRepresentative" label="客户名称" align="center"/>
          <el-table-column prop="legalRepresentative" label="客户手机号" align="center"/>
          <el-table-column prop="legalRepresentative" label="订单编号" align="center"/>
          <el-table-column prop="legalRepresentative" label="服务管家" align="center"/>
          <el-table-column prop="legalRepresentative" label="订单属性" align="center"/>
          <el-table-column prop="legalRepresentative" label="订单总价" align="center"/>
          <el-table-column prop="legalRepresentative" label="享受折扣" align="center"/>
          <el-table-column prop="legalRepresentative" label="实付金额" align="center"/>
          <el-table-column prop="legalRepresentative" label="订单状态" align="center"/>
          <el-table-column prop="legalRepresentative" label="创建时间 " align="center"/>
          <el-table-column prop="legalRepresentative" label="支付时间 " align="center"/>
        </el-table>
      </template>
      <template #footer>
        <pagination
          class="pagination"
          :total="count"
          :page.sync="pageIndex"
          :limit.sync="pageSize"
          @pagination="pagination"
        />
      </template>
    </global-card>

    <global-message
      v-if="isGlobalMessageShow"
      :message="message"
      @receive="receive"
    />
  </div>
</template>

<script>
  import ycDialog from "@/components/pageDialog"
  import perButton from "@/components/permissionButton"
  import {
    queryCompanyPage,
    queryCompanyList,
    insertCompanyPage,
    updateCompanyPage
  } from "@/api/corporationMessage/corporationInfo"
  import { queryAccountList } from "@/api/appUserControl/account"
  import { getToken } from "@/utils/auth"

  export default {
    components: {
      ycDialog,
      perButton
    },
    data() {
      return {
        tableData: [],
        pageIndex: 1,
        pageSize: 10,
        count: 0,
        searchForm: {
          agreementName: "",
          agreementType: ""
        },
        isGlobalMessageShow: false,
        message: "",
        loading: false,
        detailsDisabled: false,
        addOrUpdateLoading: false
      }
    },
    created() {
      this.getData()
    },
    methods: {
      async searchClick() {
        this.getData()
      },
      async getData() {
        const { agreementName, agreementType } = this.searchForm
        this.loading = true
        const data = await queryCompanyPage({
          pageIndex: this.pageIndex,
          pageSize: this.pageSize,
          agreementName: agreementName,
          agreementType: agreementType
        })
        this.tableData = data.object.data
        this.count = data.object.count
        this.loading = false
      },
      pagination(pageItem) {
        this.getData(pageItem.page, pageItem.limit)
      },

      receive() {
        this.isGlobalMessageShow = false
      },

      refresh() {
        this.searchForm = {
          agreementName: "",
          agreementType: ""
        }
        this.getData()
      }
    }
  }
</script>

<style lang="scss" scoped>
  .clientType {
    .title-container {
      display: flex;
      justify-content: flex-end;
      margin-right: 20px;

      .left-box {
        display: flex;

        .formClass {
          /*display: flex;*/
          /*margin-right: 20px;*/

          .el-form-item {
            margin-top: 20px;
            margin-bottom: 0;

            .el-input {
              width: 216px;
            }

            .el-select {
              width: 171px;
              margin-left: 10px;
            }

            .el-date-editor {
              width: 336px;
              margin-left: 10px;
            }
          }
        }

        /*.el-button {*/
        /*  // width: 42px;*/
        /*  height: 36px;*/
        /*  margin-top: 20px;*/
        /*}*/
      }
    }
  }
</style>
